package com.oracle.oa.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;


@Entity                        
@Table(name="message")
public class Message  implements java.io.Serializable {


	 @GenericGenerator(name = "generator", strategy = "increment")
	 @Id
	 @GeneratedValue(generator = "generator")
	 @Column(name = "messageid", unique = true, nullable = false)
     private int messageid;
	 @ManyToOne
 	 @JoinColumn(name = "userinfo_id")
     private Userinfo userinfo;
	 @ManyToOne
 	 @JoinColumn(name = "messagetype_id")
     private Messagetype messagetype;
	 @Column(name = "title", length = 64)
     private String title;
	 @Column(name = "content", length = 64)
     private String content;
	 @Column(name = "begintime", length = 64)
     private String begintime;
	 @Column(name = "endtime", length = 64)
     private String endtime;
	 @Column(name = "ifpublish")
     private int ifpublish;
	 @Column(name = "recordtime", length = 64)
     private String recordtime;
	 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "category")
     private Set messagetousers = new HashSet(0);
	 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "category")
     private Set readcommonmessages = new HashSet(0);
	public int getMessageid() {
		return messageid;
	}
	public void setMessageid(int messageid) {
		this.messageid = messageid;
	}
	public Userinfo getUserinfo() {
		return userinfo;
	}
	public void setUserinfo(Userinfo userinfo) {
		this.userinfo = userinfo;
	}
	public Messagetype getMessagetype() {
		return messagetype;
	}
	public void setMessagetype(Messagetype messagetype) {
		this.messagetype = messagetype;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getBegintime() {
		return begintime;
	}
	public void setBegintime(String begintime) {
		this.begintime = begintime;
	}
	public String getEndtime() {
		return endtime;
	}
	public void setEndtime(String endtime) {
		this.endtime = endtime;
	}
	public int getIfpublish() {
		return ifpublish;
	}
	public void setIfpublish(int ifpublish) {
		this.ifpublish = ifpublish;
	}
	public String getRecordtime() {
		return recordtime;
	}
	public void setRecordtime(String recordtime) {
		this.recordtime = recordtime;
	}
	public Set getMessagetousers() {
		return messagetousers;
	}
	public void setMessagetousers(Set messagetousers) {
		this.messagetousers = messagetousers;
	}
	public Set getReadcommonmessages() {
		return readcommonmessages;
	}
	public void setReadcommonmessages(Set readcommonmessages) {
		this.readcommonmessages = readcommonmessages;
	}
	public Message(int messageid, Userinfo userinfo, Messagetype messagetype,
			String title, String content, String begintime, String endtime,
			int ifpublish, String recordtime, Set messagetousers,
			Set readcommonmessages) {
		this.messageid = messageid;
		this.userinfo = userinfo;
		this.messagetype = messagetype;
		this.title = title;
		this.content = content;
		this.begintime = begintime;
		this.endtime = endtime;
		this.ifpublish = ifpublish;
		this.recordtime = recordtime;
		this.messagetousers = messagetousers;
		this.readcommonmessages = readcommonmessages;
	}
	public Message() {
		super();
	}
	@Override
	public String toString() {
		return "Message [messageid=" + messageid + ", userinfo=" + userinfo
				+ ", messagetype=" + messagetype + ", title=" + title
				+ ", content=" + content + ", begintime=" + begintime
				+ ", endtime=" + endtime + ", ifpublish=" + ifpublish
				+ ", recordtime=" + recordtime + ", messagetousers="
				+ messagetousers + ", readcommonmessages=" + readcommonmessages
				+ "]";
	}



}